import { withPixiApp } from '@inlet/react-pixi'
import React from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { projectLabelView as projectDuck } from 'ducks'
import { canvas as canvasDuck } from 'ducks'
import DynamicSprite from './dynamicSprite'

const ImageSpriteView = ({ isPan, paintPoint, scale, imageSrc }) => {
  return (
    <DynamicSprite
      image={imageSrc}
      anchor={[0.5, 0.5]}
      scale={scale}
      on_click={isPan === 'pan' ? () => { } : paintPoint}
    />
  )
}

const mapStateToProps = state => ({
  imageSrc: projectDuck.selectors.imageSrc(state),
  isPan: canvasDuck.selectors.isPanActive(state),
  scale: canvasDuck.selectors.imageScale(state),
})

const mapDispatchToProps = {
  paintPoint: () => { },
}

export default withPixiApp(connect(mapStateToProps, mapDispatchToProps)(ImageSpriteView))
